<template>
  <div class="app" v-show="visible">
    <div class="content">
        <div class="title">
            <span>已选商品</span>
            <span @click="clear_shopcar"><van-icon name="delete"/>清空</span>
        </div>
        <div v-if="shopcarlist.length!=0" class="list">
            <div v-for="(item,index) in shopcarlist" :key="index" class="good">
                <div class="imgbox">
                    <img :src="item.picture" alt="">
                </div>
                <div class="text">
                    <div class="name">{{item.name}}</div>
                    <div class="price">
                        <div>￥{{item.min_price}}</div>
                        <div>
                            <span @click="request_subshopcar(item)">-</span>
                            <span>{{item.count}}</span>
                            <span @click="request_addshopcar(item)">+</span>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div v-else class="empty">
            购物车空空如也~~
        </div>
    </div>
  </div>
</template>

<script>
import { mapState,mapActions } from 'vuex';
export default {
    data(){
        return{
            visible:false
        }
    },
    methods:{
        changevisible(){
            this.visible=!this.visible
        },
        ...mapActions(['clear_shopcar','request_addshopcar','request_subshopcar']),
    },
    computed:{
        ...mapState(['shopcarlist']),
    }
}
</script>

<style lang="scss" scoped>
.app{
    height: 100%;
    width: 100%;
    background-color:rgba($color: #333, $alpha: 0.5);
    position: fixed;
    top: 0;
    
}
.content {
    position: fixed;
    bottom: 55px;
    width: 100%;
    height: auto;
    box-sizing: border-box;
    background-color: #fff;

}
.content .title {
    display: flex;
    padding: 14px;
    box-sizing: border-box;
    justify-content: space-between;
    width: 100%;
}
.content .list {
    margin-bottom: 50px;
}
.content .list .good {
    display: flex;
    margin: 10px 0;
    height: 80px;
}
.content .list .good .imgbox{
    width: 80px;
    margin-left: 10px;
    img {
        width: 100%;
        height: 100%;
    }
}
.text{
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 2px 10px;
    width: 100%;
    box-sizing: border-box;
    .name{
        font-weight: bold;
    }
}
.price {
    display: flex;
    justify-content: space-between;
    div:nth-child(1){
    font-size: 18px;    
    color: red;
}
div:nth-child(2){
    width: 80px;
    display: flex;
    justify-content: space-around;
    span:nth-child(1){
        border: 1px solid rgb(9, 100, 218);
        width: 16px;
        height: 16px;
        font-size: 16px;
        line-height: 16px;
        text-align: center;
        border-radius: 100%;
        color: rgb(9, 100, 218);
        background: #fff;
    }
    span:nth-child(3){
        border: 1px solid rgb(9, 100, 218);
        width: 16px;
        height: 16px;
        font-size: 16px;
        line-height: 16px;
        text-align: center;
        border-radius: 100%;
        background: rgb(9, 100, 218);
        color: #fff;
    }
}

}
.empty {
    text-align: center;
    line-height: 120px;
}
</style>